package com.cn.lp.export.server.base.context;

import com.cn.lp.export.server.base.result.*;

/**
 * 业务异常创建器
 */
public interface ExportExceptionCreator {

    // ===========================================================================

    static ExportException create(ResultCode0 rc) {
        return new ExportException(rc.getCode(), rc.getMessage());
    }

    static ExportException create(ResultCode1 rc, Object param) {
        return new ExportException(rc.getCode(), rc.getMessage(param));
    }

    static ExportException create(ResultCode2 rc, Object param1, Object param2) {
        return new ExportException(rc.getCode(), rc.getMessage(param1, param2));
    }

    static ExportException create(ResultCode3 rc, Object param1, Object param2, Object param3) {
        return new ExportException(rc.getCode(), rc.getMessage(param1, param2, param3));
    }

    static ExportException create(ResultCode4 rc, Object param1, Object param2, Object param3, Object param4) {
        return new ExportException(rc.getCode(), rc.getMessage(param1, param2, param3, param4));
    }

    static ExportException create(int code, String msg) {
        return new ExportException(code, msg);
    }

    // ===========================================================================

    static ExportException create(ResultCode0 rc, Throwable cause) {
        return new ExportException(rc.getCode(), rc.getMessage(), cause);
    }

    static ExportException create(ResultCode1 rc, Object param, Throwable cause) {
        return new ExportException(rc.getCode(), rc.getMessage(param), cause);
    }

    static ExportException create(ResultCode2 rc, Object param1, Object param2, Throwable cause) {
        return new ExportException(rc.getCode(), rc.getMessage(param1, param2), cause);
    }

    static ExportException create(ResultCode3 rc, Object param1, Object param2, Object param3, Throwable cause) {
        return new ExportException(rc.getCode(), rc.getMessage(param1, param2, param3), cause);
    }

    static ExportException create(ResultCode4 rc, Object param1, Object param2, Object param3, Object param4, Throwable cause) {
        return new ExportException(rc.getCode(), rc.getMessage(param1, param2, param3, param4), cause);
    }

    static ExportException create(int code, String msg, Throwable cause) {
        return new ExportException(code, msg, cause);
    }

}
